package com.intelligentcar.springboot.controller;

import com.intelligentcar.springboot.bean.Role;
import com.intelligentcar.springboot.service.RoleServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
public class RoleController {
    @Autowired
    private RoleServer roleServerImpl;

    @RequestMapping("/roleTable")
    @ResponseBody
    public Map<String,Object> roleTable(@RequestBody Role role){
        return roleServerImpl.roleTable(role);
    }

    @RequestMapping("/updateRole")
    @ResponseBody
    public boolean updateRole(@RequestBody Role role){
        return roleServerImpl.updateRole(role);
    }

    @RequestMapping("/updateRoleState")
    @ResponseBody
    public boolean updateRoleState(@RequestBody Role role){
        return roleServerImpl.updateRoleState(role);
    }

    @RequestMapping("/insertRole")
    @ResponseBody
    public boolean insertRole(@RequestBody Role role){
        return roleServerImpl.insertRole(role);
    }

    @RequestMapping("/selectRole")
    @ResponseBody
    public Map<String,Object> selectRole(@RequestBody Role role){
        return roleServerImpl.selectRole(role);
    }

    //查询角色表中的所有角色
    @RequestMapping("/selectrole")
    @ResponseBody
    public Map selectrole() {
        Map map = new HashMap();
        map.put("list",roleServerImpl.selectrole());
        return map;
    }

}
